/**
 * Created by Carl on 2019/2/18
 */
export default {
  bind(el){
    console.dir(el)
    el.addEventListener("touchmove", function (e) {
      e.preventDefault()
      let _x = e.touches[0].clientX;
      let _y = e.touches[0].clientY;
      el.style.top = Number(_y - el.offsetTop/2) + 'px'
      el.style.left = Number(_x - el.offsetLeft/2) + 'px'
    })
    el.addEventListener("touchend", function (e) {
      // el.className += " " + 'skewing'
      let _x = e.changedTouches[0].clientX;
      let _y = e.changedTouches[0].clientY;
      let carouselW = document.documentElement.clientWidth
      let carouselH = document.documentElement.clientHeight
      if (Number(_x - 25) > carouselW / 2) {
        el.style.left = (carouselW - 55) + 'px'
      } else {
        el.style.left = 5 + 'px'
      }
      if (Number(_y - 25) > (carouselH - 55)) {
        el.style.top = (carouselH - 95) + 'px'
      }
      if (Number(_y - 25) < 55) {
        el.style.top = 5 + 'px'
      }
    })
  }
}
